#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "libMain.h"

#define MAX_PRICE 100.0
                                                                            // Function to generate a random ISBN
void generateISBN(char ISBN[]) {
    for (int i = 0; i < 13; i++) {
        ISBN[i] = '0' + rand() % 10;
    }
    ISBN[13] = '\0';
}

                                                                        // Function to generate a random book name
void generateName(char name[]) {
    char vowels[] = "aeiou";
    char consonants[] = "bcdfghjklmnpqrstvwxyz";

    int length = rand() % MAX_AUTH_NAME + 1;
    int startWithVowel = rand() % 2;

    for (int i = 0; i < length; i++) {
        if (i % 2 == startWithVowel) {
            name[i] = vowels[rand() % strlen(vowels)];
        }
        else {
            name[i] = consonants[rand() % strlen(consonants)];
        }
    }
    name[length] = '\0';
}
void generateAuth(char auth[]) {
    char vowels[] = "aeiou";
    char consonants[] = "bcdfghjklmnpqrstvwxyz";

    int length = rand() % MAX_AUTH_NAME + 1;
    int startWithVowel = rand() % 2;

    for (int i = 0; i < length; i++) {
        if (i % 2 == startWithVowel) {
            auth[i] = vowels[rand() % strlen(vowels)];
        }
        else {
            auth[i] = consonants[rand() % strlen(consonants)];
        }
    }
    auth[length] = '\0';
}

                                                                                        // Function to generate a random book price
float generatePrice() {
    return (float)(rand() % (int)(MAX_PRICE * 100)) / 100.0;
}